package com.codingfuture.erp_system.service.impl;

import com.codingfuture.erp_system.entity.Supplier;
import com.codingfuture.erp_system.mapper.SupplierMapper;
import com.codingfuture.erp_system.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class SupplierServiceImpl implements SupplierService {
    @Autowired
    private SupplierMapper supplierMapper;

    @Override
    public List<Supplier> findByAll(Supplier supplier) {
        return supplierMapper.findByAll(supplier);
    }

    @Override
    public List<Supplier> findByAll() {
        return null;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean insertSupplier(Supplier supplier) {
        return supplierMapper.insertSupplier(supplier) != 0;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean deleteSupplier(Integer id) {
        return supplierMapper.deleteSupplier(id) != 0;
    }

    @Override
    public Supplier findById(Integer id) {
        return supplierMapper.findById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updateSupplier(Supplier supplier) {
        return supplierMapper.updateSupplier(supplier) != 0;
    }

    @Override
    public Supplier findByName(String name) {
        return supplierMapper.findByName(name);
    }


}
